package cn.ncu.wechat.service.impl;

import cn.ncu.wechat.util.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ncu.wechat.model.MemberBenefit;
import cn.ncu.wechat.service.MemberBenefitService;
import cn.ncu.wechat.dao.MemberBenefitMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 
* @description 针对表【member_benefit(会员权益表)】的数据库操作Service实现
* @createDate 2025-01-07 16:09:13
*/
@Service
public class MemberBenefitServiceImpl extends ServiceImpl<MemberBenefitMapper, MemberBenefit>
    implements MemberBenefitService{
    @Autowired
    private MemberBenefitMapper memberBenefitMapper;
    public Result<?> getBenefitList(){
        try{
            return Result.success(memberBenefitMapper.selectList(null));
        }catch (Exception e){
            return Result.error(500,"服务器异常"+e);
        }
    }

    public Result<?> editOrAddBenefitList(MemberBenefit memberBenefit){
        try{
            if (memberBenefitMapper.insertOrUpdate(memberBenefit)){
                return Result.success("保存成功");
            }
            return Result.error(500,"服务器错误,插入失败");
        }catch (Exception e){
            return Result.error(500,"服务器异常"+e);
        }
    }
}




